package ooday04;

public class Test {
    public static void main(String[] args) {
        Animals[] animals = new Animals[5];
        animals[0] = new Dog("小黑", 2, "黑");
        animals[1] = new Dog("小白", 1, "白");
        animals[2] = new Fish("小金", 1, "金");
        animals[3] = new Fish("泡泡", 2, "红");
        animals[4] = new Chick("坤坤", 1, "黑白");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog) {
                Dog dog = (Dog) animals[i];
                dog.lookHome();
                dog.swim();
            }
            if (animals[i] instanceof Chick) {
                Chick chick = (Chick) animals[i];
                chick.layEgg();
            }
            if (animals[i] instanceof Fish) {
                Fish fish = (Fish) animals[i];
                fish.swim();
            }

        }

        Master master = new Master();
        Animals dog = new Dog("旺财",1,"黄");
        Animals fish = new Fish("泡泡",2,"金");
        Animals chick = new Chick("坤坤",2,"棕");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);

    }
}

